package com.yanqu.road.entity.activity.peakstronghold;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.math.BigInteger;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_u_peakstronghold_data", desc = "巅峰据点战玩家个人信息", autoSave = true)
public class UserPeakStrongholdWarData extends DataObject {
    @FieldTypeAnnotation(select = true, update = true, desc = "用户id", isIndex = true)
    private long userId;
    @FieldTypeAnnotation(select = true, update = true, desc = "活动id", isIndex = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "捐献累计donateId=donateNum")
    private Map<Integer,Integer> donateNumMap;
    @FieldTypeAnnotation(desc = "累计捐献经验")
    private int donateExp;
    @FieldTypeAnnotation(desc = "银两捐献累计")
    private BigInteger silverAmount = BigInteger.ZERO;
    @FieldTypeAnnotation(desc = "银两捐献轮次")
    private int silverRound;
    @FieldTypeAnnotation(desc = "门客进攻重置回合")
    private int resetPatronsRound;
    @FieldTypeAnnotation(desc = "累计伤害")
    private BigInteger totalDamage = BigInteger.ZERO;
    @FieldTypeAnnotation(desc = "是否膜拜")
    private boolean isWorship = false;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public BigInteger getSilverAmount() {
        return silverAmount;
    }

    public void setSilverAmount(BigInteger silverAmount) {
        if (this.silverAmount.compareTo(silverAmount) != 0) {
            this.silverAmount = silverAmount;
            setUpdateOption();
        }
    }
    public void addSilverAmount(BigInteger silver) {
        this.silverAmount = this.silverAmount.add(silver);
        setUpdateOption();
    }

    public int getSilverRound() {
        return silverRound;
    }

    public void setSilverRound(int silverRound) {
        if (this.silverRound != silverRound) {
            this.silverRound = silverRound;
            setUpdateOption();
        }
    }

    public int getDonateExp() {
        return donateExp;
    }

    public void setDonateExp(int donateExp) {
        if (this.donateExp != donateExp) {
            this.donateExp = donateExp;
            setUpdateOption();
        }
    }

    public Map<Integer, Integer> getDonateNumMap() {
        return donateNumMap;
    }

    public void setDonateNumMap(Map<Integer, Integer> donateNumMap) {
        this.donateNumMap = donateNumMap;
    }

    public int getDonateNum(int donateId) {
        if (donateNumMap.containsKey(donateId)) {
            return donateNumMap.get(donateId);
        }
        return 0;
    }

    public void addDonateNum(int donateId, int addNum) {
        int num = getDonateNum(donateId);
        donateNumMap.put(donateId, num + addNum);
        setUpdateOption();
    }

    public int getResetPatronsRound() {
        return resetPatronsRound;
    }

    public void setResetPatronsRound(int resetPatronsRound) {
        if (this.resetPatronsRound != resetPatronsRound) {
            this.resetPatronsRound = resetPatronsRound;
            setUpdateOption();
        }
    }

    public BigInteger getTotalDamage() {
        return totalDamage;
    }

    public void setTotalDamage(BigInteger totalDamage) {
        if (this.totalDamage.compareTo(totalDamage) != 0) {
            this.totalDamage = totalDamage;
            setUpdateOption();
        }
    }

    public boolean isWorship() {
        return isWorship;
    }

    public void setWorship(boolean worship) {
        if(worship != this.isWorship){
            isWorship = worship;
            setUpdateOption();
        }
    }
}
